

// /v2/movie/celebrity/1054395

// http://api.douban.com/v2/movie/subject/1764796?apikey=0df993c66c0c636e29ecbb5344252a4a

//第三方request-promise-native跨域请求工具，通常请求api，需要安装
const rp=require('request-promise-native')
async function fetchMovie(item) {
    const url=`https://api.douban.com/v2/movie/subject/${item.doubanId}?apikey=0df993c66c0c636e29ecbb5344252a4a`
    const res=await rp(url)
    return res
}

;(async ()=>{
    let movies = [
        {

            doubanId: 34961628,
            title: '无敌的宙斯机',
            pic:'https://img1.doubanio.com/view/photo/l_ratio_poster/public/p2587067778.jpg',
            rate: ''
        },
        {
            doubanId: 34960027,
            title: '外星人爆发',
            pic:'https://img9.doubanio.com/view/photo/l_ratio_poster/public/p2583403126.jpg',
            rate: '4.0'
        }
    ];

    movies.map(async movie=>{  //map数组每个元素执行，传数组值，这里是一个对象
        let movieData=await fetchMovie(movie)  //往fetchMovie方法传 对象数据，会返回一个res
        try{
            let  data=JSON.parse(movieData)
            console.log(data.tags)
            console.log(data.summary)
        }catch(e){
            console.log(e)
        }
    })
})()